<template>
    <div>
        <div class="userpicture">
            <van-image round width="10rem" height="10rem" src="https://fastly.jsdelivr.net/npm/@vant/assets/cat.jpeg" />
            <h2>{{ info.username }}</h2>
        </div>
        <div>
            <van-cell-group>
                <van-cell title="修改个人信息" is-link to="/updateuser"/>
                <van-cell title="我的收藏" is-link to="/collect" />
                <van-cell title="我的订单" is-link to="/order" />
                <van-cell title="我的评论" is-link to="/comment" />
                <van-cell title="注销登录" @click="logout" is-link />
            </van-cell-group>
        </div>
    </div>
</template>

<script setup>
import { ref,reactive,onMounted } from 'vue';
import { useCounterStore } from '@/stores/counter';
import { useRouter } from 'vue-router';
import { getUserApi } from '@/api';
const store = useCounterStore()
const router = useRouter()
const info = ref({})
const getUser = async e => {
    const res = await getUserApi(e);
    info.value=res;
  };
//注销
const logout=()=>{
    store.clearId()
    router.push('/')
}
onMounted(()=>{
    getUser(store.userId)
})
</script>

<style  scoped>
.userpicture{
    margin-top: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
}
</style>